package cn.zebra.dev.other.module.shopapply.service.impl;

import cn.zebra.dev.ibatis.plus.service.impl.ServiceImpl;
import cn.zebra.dev.ibatis.plus.utils.PageUtils;
import cn.zebra.dev.ibatis.plus.utils.Query;
import cn.zebra.dev.other.module.shopapply.dao.ShopApplyDao;
import cn.zebra.dev.other.module.shopapply.entity.ShopApplyEntity;
import cn.zebra.dev.other.module.shopapply.service.ShopApplyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author runnable
 */
@Service
public class ShopApplyServiceImpl extends ServiceImpl<ShopApplyDao, ShopApplyEntity> implements ShopApplyService {

    @Override
    public PageUtils<ShopApplyEntity> findPage(Map<String, Object> params) {
        QueryWrapper<ShopApplyEntity> wrapper = new QueryWrapper<>();
        if(params.get("state") != null){
            wrapper.apply("state = {0}",params.get("state"));
        }
        if(params.get("userId") != null){
            wrapper.apply("user_id = {0}",params.get("userId"));
        }
        IPage<ShopApplyEntity> page = this.page(
                new Query<ShopApplyEntity>(params).getPage(),
                wrapper
        );

        return new PageUtils<>(page);
    }

}
